/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.system.source.connector;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Pinds
 */
public class DataBaseConnection {

    private static Connection conn;

    public static Connection getConnection() {
        if (conn == null) {
            try {
                DriverManager.registerDriver(new com.mysql.jdbc.Driver());
                conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/emovie", "root", "");
            } catch (SQLException ex) {
                Logger.getLogger(DataBaseConnection.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return conn;
    }

    public static void closeConnection() {
        try {
            conn.close();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,"Tutup koneksi gagal...." + ex);
        }
    }
}
